<commit_before>if (typeof PATH_TO_THE_REPO_PATH_UTILS_FILE === 'undefined') PATH_TO_THE_REPO_PATH_UTILS_FILE = "https://raw.githubusercontent.com/highfidelity/hifi_tests/master/tests/utils/branchUtils.js";
Script.include(PATH_TO_THE_REPO_PATH_UTILS_FILE);
var nitpick = createNitpick(Script.resolvePath("."));

nitpick.perform("LOD test", Script.resolvePath("."), "secondary", function(testType) {
    var createdOverlays = [];

    var LIFETIME = 120;
    var DIM = {x: 1.0, y: 1.2, z: 0.28};

    var previousLODAdjust;
    var octreeSizeScale;

    MyAvatar.orientation = Quat.fromPitchYawRollDegrees(0.0, 0.0, 0.0);

    var pos = nitpick.getOriginFrame();
    var ori = MyAvatar.orientation;

    validationCamera_setRotation({ x: 0.0, y: 0.0, z: 0.0 });
    validationCamera_setTranslation({ x: 0.0, y: 0.0, z: 0.0 });

    // Create line of models
    var assetsRootPath = nitpick.getAssetsRootPath();
    var URL = Script.resolvePath(assetsRootPath + "models/geometry/avatars/kaya/Kaya.fbx");
    createdOverlays.push(Overlays.addOverlay("model", {
        position: Vec3.sum(Vec3.sum(Vec3.sum(pos, Vec3.multiply(1.6, Quat.getUp(ori))), Vec3.multiply(-0.5, Quat.getRight(ori))), Vec3.multiply(2.8, Quat.getForward(ori))),
        lifetime: LIFETIME,
        url: URL,
        dimensions: DIM,
        orientation: ori,
        isGroupCulled: false,
        isVisibleInSecondaryCamera: true
    }));

    createdOverlays.push(Overlays.addOverlay("model", {
        position: Vec3.sum(Vec3.sum(Vec3.sum(pos, Vec3.multiply(1.6, Quat.getUp(ori))), Vec3.multiply(0.5, Quat.getRight(ori))), Vec3.multiply(2.8, Quat.getForward(ori))),
        lifetime: LIFETIME,
        url: URL,
        dimensions: DIM,
        orientation: ori,
        isGroupCulled: true,
        isVisibleInSecondaryCamera: true
    }));

    previousLODAdjust = LODManager.getAutomaticLODAdjust();
    LODManager.setAutomaticLODAdjust(false);

    octreeSizeScale = LODManager.getOctreeSizeScale();
    LODManager.setOctreeSizeScale(32768 * 400);

    nitpick.addStepSnapshot("Both models visible");

    nitpick.addStep("Set LOD to 60", function () {
        LODManager.setOctreeSizeScale(32768 * 60);
    });
    nitpick.addStepSnapshot("Eyes of left model cannot be seen");

    nitpick.addStep("Set LOD to 10", function () {
        LODManager.setOctreeSizeScale(32768 * 10);
    });
    nitpick.addStepSnapshot("Only right model visible, including eyes");

    nitpick.addStep("Set LOD to 4", function () {
        LODManager.setOctreeSizeScale(32768 * 4);
    });
    nitpick.addStepSnapshot("No models are visible");

    nitpick.addStep("Clean up", function () {
        for (var i = 0; i < createdOverlays.length; i++) {
            Overlays.deleteOverlay(createdOverlays[i]);
        }

        LODManager.setOctreeSizeScale(octreeSizeScale);
        LODManager.setAutomaticLODAdjust(previousLODAdjust);
    });

    nitpick.runTest(testType);
});<commit_msg>Restored to master version.<commit_after>if (typeof PATH_TO_THE_REPO_PATH_UTILS_FILE === 'undefined') PATH_TO_THE_REPO_PATH_UTILS_FILE = "https://raw.githubusercontent.com/highfidelity/hifi_tests/master/tests/utils/branchUtils.js";
Script.include(PATH_TO_THE_REPO_PATH_UTILS_FILE);
var nitpick = createNitpick(Script.resolvePath("."));

nitpick.perform("LOD test", Script.resolvePath("."), "secondary", function(testType) {
    var createdOverlays = [];

    var LIFETIME = 120;
    var DIM = {x: 1.0, y: 1.2, z: 0.28};

    MyAvatar.orientation = Quat.fromPitchYawRollDegrees(0.0, 0.0, 0.0);

    var pos = nitpick.getOriginFrame();
    var ori = MyAvatar.orientation;

    validationCamera_setRotation({ x: 0.0, y: 0.0, z: 0.0 });
    validationCamera_setTranslation({ x: 0.0, y: 0.0, z: 0.0 });

    // Create line of models
    var assetsRootPath = nitpick.getAssetsRootPath();
    var URL = Script.resolvePath(assetsRootPath + "models/geometry/avatars/kaya/Kaya.fbx");
    createdOverlays.push(Overlays.addOverlay("model", {
        position: Vec3.sum(Vec3.sum(Vec3.sum(pos, Vec3.multiply(1.6, Quat.getUp(ori))), Vec3.multiply(-0.5, Quat.getRight(ori))), Vec3.multiply(2.8, Quat.getForward(ori))),
        lifetime: LIFETIME,
        url: URL,
        dimensions: DIM,
        orientation: ori,
        isGroupCulled: false,
        isVisibleInSecondaryCamera: true
    }));

    createdOverlays.push(Overlays.addOverlay("model", {
        position: Vec3.sum(Vec3.sum(Vec3.sum(pos, Vec3.multiply(1.6, Quat.getUp(ori))), Vec3.multiply(0.5, Quat.getRight(ori))), Vec3.multiply(2.8, Quat.getForward(ori))),
        lifetime: LIFETIME,
        url: URL,
        dimensions: DIM,
        orientation: ori,
        isGroupCulled: true,
        isVisibleInSecondaryCamera: true
    }));

    LODManager.setAutomaticLODAdjust(false);
    LODManager.setOctreeSizeScale(32768 * 400);

    nitpick.addStepSnapshot("Both models visible");

    nitpick.addStep("Set LOD to 60", function () {
        LODManager.setOctreeSizeScale(32768 * 60);
    });
    nitpick.addStepSnapshot("Eyes of left model cannot be seen");

    nitpick.addStep("Set LOD to 10", function () {
        LODManager.setOctreeSizeScale(32768 * 10);
    });
    nitpick.addStepSnapshot("Only right model visible, including eyes");

    nitpick.addStep("Set LOD to 4", function () {
        LODManager.setOctreeSizeScale(32768 * 4);
    });
    nitpick.addStepSnapshot("No models are visible");

    nitpick.addStep("Clean up", function () {
        for (var i = 0; i < createdOverlays.length; i++) {
            Overlays.deleteOverlay(createdOverlays[i]);
        }

        LODManager.setOctreeSizeScale(32768 * 400);
        LODManager.setAutomaticLODAdjust(true);
    });

    nitpick.runTest(testType);
});<|endoftext|>


<commit_before>var emojichar2gifnum = {
    "\uE63E": "111", "\uE63F": "112", "\uE640": "249", "\uE641": "156", "\uE642": "157",
    "\uE643": "089", "\uE644": "160", "\uE645": "097", "\uE646": "243", "\uE647": "242",
    "\uE648": "088", "\uE649": "247", "\uE64A": "129", "\uE64B": "229", "\uE64C": "093",
    "\uE64D": "146", "\uE64E": "096", "\uE64F": "098", "\uE650": "117", "\uE651": "252",
    "\uE652": "072", "\uE653": "154", "\uE654": "063", "\uE655": "078", "\uE656": "064",
    "\uE657": "069", "\uE658": "194", "\uE659": "220", "\uE65A": "214", "\uE65B": "159",
    "\uE65C": "091", "\uE65D": "108", "\uE65E": "150", "\uE65F": "151", "\uE660": "193",
    "\uE661": "145", "\uE662": "161", "\uE663": "238", "\uE664": "203", "\uE665": "153",
    "\uE666": "130", "\uE667": "155", "\uE668": "164", "\uE669": "212", "\uE66A": "062",
    "\uE66B": "166", "\uE66C": "162", "\uE66D": "084", "\uE66E": "186", "\uE66F": "226",
    "\uE670": "236", "\uE671": "197", "\uE672": "204", "\uE673": "205", "\uE674": "208",
    "\uE675": "140", "\uE676": "052", "\uE677": "239", "\uE678": "233", "\uE679": "152",
    "\uE67A": "250", "\uE67B": "044", "\uE67C": "241", "\uE67D": "045", "\uE67E": "075",
    "\uE67F": "235", "\uE680": "138", "\uE681": "051", "\uE682": "050", "\uE683": "114",
    "\uE684": "224", "\uE685": "209", "\uE686": "198", "\uE687": "158", "\uE688": "107",
    "\uE689": "217", "\uE68A": "168", "\uE68B": "060", "\uE68C": "165", "\uE68D": "191",
    "\uE68E": "071", "\uE68F": "073", "\uE690": "054", "\uE691": "131", "\uE692": "142",
    "\uE693": "101", "\uE694": "102", "\uE695": "103", "\uE696": "234", "\uE697": "099",
    "\uE698": "148", "\uE699": "039", "\uE69A": "245", "\uE69B": "149", "\uE69C": "109",
    "\uE69D": "182", "\uE69E": "087", "\uE69F": "082", "\uE6A0": "123", "\uE6A1": "126",
    "\uE6A2": "127", "\uE6A3": "223", "\uE6A4": "056", "\uE6A5": "100", "\uE6AC": "049",
    "\uE6AD": "175", "\uE6AE": "210", "\uE6B1": "083", "\uE6B2": "030", "\uE6B3": "092",
    "\uE6B7": "025", "\uE6B8": "023", "\uE6B9": "011", "\uE6BA": "110", "\uE6CE": "024",
    "\uE6CF": "021", "\uE6D0": "015", "\uE6D1": "019", "\uE6D2": "020", "\uE6D3": "218",
    "\uE6D4": "189", "\uE6D5": "188", "\uE6D6": "113", "\uE6D7": "124", "\uE6D8": "016",
    "\uE6D9": "199", "\uE6DA": "116", "\uE6DB": "055", "\uE6DC": "065", "\uE6DD": "167",
    "\uE6DE": "230", "\uE6DF": "206", "\uE6E0": "066", "\uE6E1": "219", "\uE6E2": "002",
    "\uE6E3": "003", "\uE6E4": "004", "\uE6E5": "005", "\uE6E6": "006", "\uE6E7": "007",
    "\uE6E8": "008", "\uE6E9": "009", "\uE6EA": "010", "\uE6EB": "001", "\uE6EC": "163",
    "\uE6ED": "106", "\uE6EE": "094", "\uE6EF": "192", "\uE6F0": "185", "\uE6F1": "043",
    "\uE6F2": "036", "\uE6F3": "180", "\uE6F4": "176", "\uE6F5": "059", "\uE6F6": "184",
    "\uE6F7": "029", "\uE6F8": "035", "\uE6F9": "053", "\uE6FA": "174", "\uE6FB": "173",
    "\uE6FC": "179", "\uE6FD": "202", "\uE6FE": "125", "\uE6FF": "216", "\uE700": "195",
    "\uE701": "133", "\uE702": "013", "\uE703": "012", "\uE704": "014", "\uE705": "170",
    "\uE706": "027", "\uE707": "042", "\uE708": "074", "\uE709": "080", "\uE70A": "081",
    "\uE70B": "118", "\uE70C": "017", "\uE70D": "018", "\uE70E": "026", "\uE70F": "038",
    "\uE710": "231", "\uE711": "068", "\uE712": "070", "\uE713": "076", "\uE714": "079",
    "\uE715": "190", "\uE716": "200", "\uE717": "221", "\uE718": "227", "\uE719": "248",
    "\uE71A": "244", "\uE71B": "105", "\uE71C": "136", "\uE71D": "144", "\uE71E": "121",
    "\uE71F": "143", "\uE720": "141", "\uE721": "178", "\uE722": "085", "\uE723": "086",
    "\uE724": "177", "\uE725": "213", "\uE726": "132", "\uE727": "104", "\uE728": "028",
    "\uE729": "046", "\uE72A": "032", "\uE72B": "037", "\uE72C": "128", "\uE72D": "240",
    "\uE72E": "120", "\uE72F": "022", "\uE730": "057", "\uE731": "061", "\uE732": "187",
    "\uE733": "147", "\uE734": "215", "\uE735": "222", "\uE736": "225", "\uE737": "232",
    "\uE738": "137", "\uE739": "139", "\uE73A": "090", "\uE73B": "122", "\uE73C": "135",
    "\uE73D": "134", "\uE73E": "237", "\uE73F": "119", "\uE740": "095", "\uE741": "058",
    "\uE742": "041", "\uE743": "077", "\uE744": "196", "\uE745": "183", "\uE746": "246",
    "\uE747": "181", "\uE748": "115", "\uE749": "033", "\uE74A": "067", "\uE74B": "169",
    "\uE74C": "171", "\uE74D": "201", "\uE74E": "034", "\uE74F": "172", "\uE750": "211",
    "\uE751": "251", "\uE752": "031", "\uE753": "047", "\uE754": "048", "\uE755": "207",
    "\uE756": "228", "\uE757": "040"
};

var imgUrlBase = "https://imode.net/cmn/m/ext/imail/images/iemoji/o-";

function createEmojiButton(emoji, dst){
    var img = document.createElement('img');
    if(emojichar2gifnum[emoji] == "   "){
        return null;
    }
    img.src =  imgUrlBase + emojichar2gifnum[emoji] + '.gif';
    img.charCode = emoji;
    img.onclick = function(){
        dst.contentDocument.execCommand('insertimage', false, img.src);
    };
    return img;
}

function getCharCodeByImg(img){
    var url = img.src;
    var num = url.substr(imgUrlBase.length, 3);
    for(var c in emojichar2gifnum){
        if(emojichar2gifnum[c] == num){
            return c;
        }
    }
    return "";
}

function appendEditor(dst){
    var iframe = document.createElement('iframe');
    iframe.id = "emoji_editor";
    dst.appendChild(iframe);
    iframe.contentDocument.designMode = "on";

    var emojiPalette = document.createElement('div');
    for(var emoji in emojichar2gifnum){
        var img = createEmojiButton(emoji, iframe);
        if(img){
            emojiPalette.appendChild(img);
        }
    }

    dst.appendChild(emojiPalette);
    return;
}
function showEmojiEditor(textarea){
    var parent = textarea.parentNode;
    appendEditor(parent);

    var form = document.getElementsByTagName('form')[0];
    form.onsubmit = function(){
        var editor = getEmojiEditor();
        var nodes = editor.contentDocument.body.childNodes;
        var text = "";
        for(var i in nodes){
            switch(nodes[i].nodeName){
            case 'IMG':
                text += getCharCodeByImg(nodes[i]);
            case '#text':
                text += nodes[i].data;
            }
        }
        getOriginalTextArea().value = text;
    };
};

function getEmojiEditor(){
    return document.getElementById('emoji_editor');
}

function getOriginalTextArea(){
    var textarea;
    try{
        textarea = document.getElementsByClassName('text-textarea')[0];
    } catch (e) {}
    return textarea;
}

(function(){
     var textarea = getOriginalTextArea();
     if(textarea){
         textarea.style.display = "none";
         showEmojiEditor(textarea);
     }
 })();
<commit_msg>fixed bug<commit_after>var emojichar2gifnum = {
    "\uE63E": "111", "\uE63F": "112", "\uE640": "249", "\uE641": "156", "\uE642": "157",
    "\uE643": "089", "\uE644": "160", "\uE645": "097", "\uE646": "243", "\uE647": "242",
    "\uE648": "088", "\uE649": "247", "\uE64A": "129", "\uE64B": "229", "\uE64C": "093",
    "\uE64D": "146", "\uE64E": "096", "\uE64F": "098", "\uE650": "117", "\uE651": "252",
    "\uE652": "072", "\uE653": "154", "\uE654": "063", "\uE655": "078", "\uE656": "064",
    "\uE657": "069", "\uE658": "194", "\uE659": "220", "\uE65A": "214", "\uE65B": "159",
    "\uE65C": "091", "\uE65D": "108", "\uE65E": "150", "\uE65F": "151", "\uE660": "193",
    "\uE661": "145", "\uE662": "161", "\uE663": "238", "\uE664": "203", "\uE665": "153",
    "\uE666": "130", "\uE667": "155", "\uE668": "164", "\uE669": "212", "\uE66A": "062",
    "\uE66B": "166", "\uE66C": "162", "\uE66D": "084", "\uE66E": "186", "\uE66F": "226",
    "\uE670": "236", "\uE671": "197", "\uE672": "204", "\uE673": "205", "\uE674": "208",
    "\uE675": "140", "\uE676": "052", "\uE677": "239", "\uE678": "233", "\uE679": "152",
    "\uE67A": "250", "\uE67B": "044", "\uE67C": "241", "\uE67D": "045", "\uE67E": "075",
    "\uE67F": "235", "\uE680": "138", "\uE681": "051", "\uE682": "050", "\uE683": "114",
    "\uE684": "224", "\uE685": "209", "\uE686": "198", "\uE687": "158", "\uE688": "107",
    "\uE689": "217", "\uE68A": "168", "\uE68B": "060", "\uE68C": "165", "\uE68D": "191",
    "\uE68E": "071", "\uE68F": "073", "\uE690": "054", "\uE691": "131", "\uE692": "142",
    "\uE693": "101", "\uE694": "102", "\uE695": "103", "\uE696": "234", "\uE697": "099",
    "\uE698": "148", "\uE699": "039", "\uE69A": "245", "\uE69B": "149", "\uE69C": "109",
    "\uE69D": "182", "\uE69E": "087", "\uE69F": "082", "\uE6A0": "123", "\uE6A1": "126",
    "\uE6A2": "127", "\uE6A3": "223", "\uE6A4": "056", "\uE6A5": "100", "\uE6AC": "049",
    "\uE6AD": "175", "\uE6AE": "210", "\uE6B1": "083", "\uE6B2": "030", "\uE6B3": "092",
    "\uE6B7": "025", "\uE6B8": "023", "\uE6B9": "011", "\uE6BA": "110", "\uE6CE": "024",
    "\uE6CF": "021", "\uE6D0": "015", "\uE6D1": "019", "\uE6D2": "020", "\uE6D3": "218",
    "\uE6D4": "189", "\uE6D5": "188", "\uE6D6": "113", "\uE6D7": "124", "\uE6D8": "016",
    "\uE6D9": "199", "\uE6DA": "116", "\uE6DB": "055", "\uE6DC": "065", "\uE6DD": "167",
    "\uE6DE": "230", "\uE6DF": "206", "\uE6E0": "066", "\uE6E1": "219", "\uE6E2": "002",
    "\uE6E3": "003", "\uE6E4": "004", "\uE6E5": "005", "\uE6E6": "006", "\uE6E7": "007",
    "\uE6E8": "008", "\uE6E9": "009", "\uE6EA": "010", "\uE6EB": "001", "\uE6EC": "163",
    "\uE6ED": "106", "\uE6EE": "094", "\uE6EF": "192", "\uE6F0": "185", "\uE6F1": "043",
    "\uE6F2": "036", "\uE6F3": "180", "\uE6F4": "176", "\uE6F5": "059", "\uE6F6": "184",
    "\uE6F7": "029", "\uE6F8": "035", "\uE6F9": "053", "\uE6FA": "174", "\uE6FB": "173",
    "\uE6FC": "179", "\uE6FD": "202", "\uE6FE": "125", "\uE6FF": "216", "\uE700": "195",
    "\uE701": "133", "\uE702": "013", "\uE703": "012", "\uE704": "014", "\uE705": "170",
    "\uE706": "027", "\uE707": "042", "\uE708": "074", "\uE709": "080", "\uE70A": "081",
    "\uE70B": "118", "\uE70C": "017", "\uE70D": "018", "\uE70E": "026", "\uE70F": "038",
    "\uE710": "231", "\uE711": "068", "\uE712": "070", "\uE713": "076", "\uE714": "079",
    "\uE715": "190", "\uE716": "200", "\uE717": "221", "\uE718": "227", "\uE719": "248",
    "\uE71A": "244", "\uE71B": "105", "\uE71C": "136", "\uE71D": "144", "\uE71E": "121",
    "\uE71F": "143", "\uE720": "141", "\uE721": "178", "\uE722": "085", "\uE723": "086",
    "\uE724": "177", "\uE725": "213", "\uE726": "132", "\uE727": "104", "\uE728": "028",
    "\uE729": "046", "\uE72A": "032", "\uE72B": "037", "\uE72C": "128", "\uE72D": "240",
    "\uE72E": "120", "\uE72F": "022", "\uE730": "057", "\uE731": "061", "\uE732": "187",
    "\uE733": "147", "\uE734": "215", "\uE735": "222", "\uE736": "225", "\uE737": "232",
    "\uE738": "137", "\uE739": "139", "\uE73A": "090", "\uE73B": "122", "\uE73C": "135",
    "\uE73D": "134", "\uE73E": "237", "\uE73F": "119", "\uE740": "095", "\uE741": "058",
    "\uE742": "041", "\uE743": "077", "\uE744": "196", "\uE745": "183", "\uE746": "246",
    "\uE747": "181", "\uE748": "115", "\uE749": "033", "\uE74A": "067", "\uE74B": "169",
    "\uE74C": "171", "\uE74D": "201", "\uE74E": "034", "\uE74F": "172", "\uE750": "211",
    "\uE751": "251", "\uE752": "031", "\uE753": "047", "\uE754": "048", "\uE755": "207",
    "\uE756": "228", "\uE757": "040"
};

var imgUrlBase = "https://imode.net/cmn/m/ext/imail/images/iemoji/o-";

function createEmojiButton(emoji, dst){
    var img = document.createElement('img');
    if(emojichar2gifnum[emoji] == "   "){
        return null;
    }
    img.src =  imgUrlBase + emojichar2gifnum[emoji] + '.gif';
    img.charCode = emoji;
    img.onclick = function(){
        dst.contentDocument.execCommand('insertimage', false, img.src);
    };
    return img;
}

function getCharCodeByImg(img){
    var url = img.src;
    var num = url.substr(imgUrlBase.length, 3);
    for(var c in emojichar2gifnum){
        if(emojichar2gifnum[c] == num){
            return c;
        }
    }
    return "";
}

function appendEditor(dst){
    var iframe = document.createElement('iframe');
    iframe.id = "emoji_editor";
    dst.appendChild(iframe);
    iframe.contentDocument.designMode = "on";

    var emojiPalette = document.createElement('div');
    for(var emoji in emojichar2gifnum){
        var img = createEmojiButton(emoji, iframe);
        if(img){
            emojiPalette.appendChild(img);
        }
    }

    dst.appendChild(emojiPalette);
    return;
}
function showEmojiEditor(textarea){
    var parent = textarea.parentNode;
    appendEditor(parent);

    var form = document.getElementsByTagName('form')[0];
    form.onsubmit = function(){
        var editor = getEmojiEditor();
        var nodes = editor.contentDocument.body.childNodes;
        var text = "";
        for(var i in nodes){
            switch(nodes[i].nodeName){
            case 'IMG':
                text += getCharCodeByImg(nodes[i]);
                break;
            case '#text':
                text += nodes[i].data;
                break;
            default:
            }
        }
        getOriginalTextArea().value = text;
    };
};

function getEmojiEditor(){
    return document.getElementById('emoji_editor');
}

function getOriginalTextArea(){
    var textarea;
    try{
        textarea = document.getElementsByClassName('text-textarea')[0];
    } catch (e) {}
    return textarea;
}

(function(){
     var textarea = getOriginalTextArea();
     if(textarea){
         textarea.style.display = "none";
         showEmojiEditor(textarea);
     }
 })();
<|endoftext|>


<commit_before>/*
 * This file is part of the Sylius package.
 *
 * (c) Paweł Jędrzejewski
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

(function ($) {
    'use strict';

    $.fn.extend({
        notification: function () {
            var HUB_REQUEST_TIME = 'hub_request_time';
            var LAST_SYLIUS_VERSION = 'last_sylius_version';
            var SYLIUS_VERSION_DISMISSED = 'sylius_version_dismissed';
            var MILISECONDS_MULTIPLIER = 1000;

            var notificationMenu = $('#sylius-version-notification');
            var askFrequency = notificationMenu.attr('data-frequency') * MILISECONDS_MULTIPLIER;

            initializeWidget();

            if (retrieve(HUB_REQUEST_TIME) === undefined || milisecondsSinceLastRequest() > askFrequency) {
                askVersion();
            }

            $(notificationMenu).find('i[data-dismiss]').on('click', function () {
                store(SYLIUS_VERSION_DISMISSED, retrieve(LAST_SYLIUS_VERSION));

                notify(false);
            });

            function askVersion() {
                $.ajax({
                    type: "GET",
                    url: notificationMenu.attr('data-url'),
                    accept: "application/json",
                    success: function (data) {
                        if (undefined !== data && data.version !== retrieve(LAST_SYLIUS_VERSION)) {
                            store(LAST_SYLIUS_VERSION, data.version.toString());

                            initializeWidget();
                        }
                    },
                    complete: function () {
                        store(HUB_REQUEST_TIME, new Date().getTime().toString());
                    }
                });
            }

            function initializeWidget() {
                if (undefined === retrieve(LAST_SYLIUS_VERSION)) {
                    store(LAST_SYLIUS_VERSION, notificationMenu.data('current-version'));
                }
                if (undefined === retrieve(SYLIUS_VERSION_DISMISSED)) {
                    store(SYLIUS_VERSION_DISMISSED, '0');
                }

                if (retrieve(LAST_SYLIUS_VERSION) === notificationMenu.data('current-version') || retrieve(LAST_SYLIUS_VERSION) === retrieve(SYLIUS_VERSION_DISMISSED)) {
                    notify(false);
                } else {
                    notify(true);
                }
            }

            function notify(bool) {
                var notificationMenu = $('#sylius-version-notification');

                if (true === bool) {
                    $('#notifications').css('display', 'block');
                    $('#no-notifications').css('display', 'none');
                    notificationMenu.find('.bell.icon').removeClass('outline').addClass('yellow');
                } else {
                    $('#notifications').css('display', 'none');
                    $('#no-notifications').css('display', 'block');
                    notificationMenu.find('.bell.icon').removeClass('yellow').addClass('outline');
                }
            }

            function milisecondsSinceLastRequest() {
                return new Date().getTime() - parseInt(retrieve(HUB_REQUEST_TIME));
            }

            function store(key, value) {
                localStorage.setItem(key, value);
            }
            function retrieve(key) {
                return localStorage.getItem(key);
            }
        }
    });
})(jQuery);
<commit_msg>Refactor version notifier code<commit_after>/*
 * This file is part of the Sylius package.
 *
 * (c) Paweł Jędrzejewski
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

(function ($) {
    'use strict';

    $.fn.extend({
        notification: function () {
            var HUB_REQUEST_TIME = 'hub_request_time';
            var LAST_SYLIUS_VERSION = 'last_sylius_version';
            var SYLIUS_VERSION_DISMISSED = 'sylius_version_dismissed';
            var MILISECONDS_MULTIPLIER = 1000;

            var notificationMenu = $('#sylius-version-notification');
            var askFrequency = notificationMenu.attr('data-frequency') * MILISECONDS_MULTIPLIER;

            $(notificationMenu).find('i[data-dismiss]').on('click', function () {
                store(SYLIUS_VERSION_DISMISSED, getLatestSyliusVersion());

                updateNotification();
            });

            updateNotification();

            function updateNotification() {
                if (isLatest() || isDismissed()) {
                    hideNotification();

                    return;
                }

                showNotification();
            }

            function showNotification()
            {
                var notificationMenu = $('#sylius-version-notification');

                $('#notifications').css('display', 'block');
                $('#no-notifications').css('display', 'none');
                notificationMenu.find('.bell.icon').removeClass('outline').addClass('yellow');
            }

            function hideNotification()
            {
                var notificationMenu = $('#sylius-version-notification');

                $('#notifications').css('display', 'none');
                $('#no-notifications').css('display', 'block');
                notificationMenu.find('.bell.icon').removeClass('yellow').addClass('outline');
            }

            function getCurrentSyliusVersion()
            {
                return notificationMenu.data('current-version');
            }

            function getLatestSyliusVersion()
            {
                if (retrieve(HUB_REQUEST_TIME) !== undefined && milisecondsSinceLastRequest() < askFrequency) {
                    return retrieve(LAST_SYLIUS_VERSION);
                }

                $.ajax({
                    type: "GET",
                    url: notificationMenu.attr('data-url'),
                    accept: "application/json",
                    success: function (data) {
                        if (undefined !== data && data.version !== retrieve(LAST_SYLIUS_VERSION)) {
                            store(LAST_SYLIUS_VERSION, data.version.toString());
                        }
                    },
                    complete: function () {
                        store(HUB_REQUEST_TIME, new Date().getTime().toString());
                    }
                });

                return retrieve(LAST_SYLIUS_VERSION);
            }

            function getDismissedSyliusVersion()
            {
                return retrieve(SYLIUS_VERSION_DISMISSED);
            }

            function isLatest()
            {
                return getCurrentSyliusVersion() === getLatestSyliusVersion();
            }

            function isDismissed()
            {
                return getLatestSyliusVersion() === getDismissedSyliusVersion();
            }

            function milisecondsSinceLastRequest() {
                return new Date().getTime() - parseInt(retrieve(HUB_REQUEST_TIME));
            }

            function store(key, value) {
                localStorage.setItem(key, value);
            }

            function retrieve(key) {
                return localStorage.getItem(key);
            }
        }
    });
})(jQuery);
<|endoftext|>


<commit_before>/* XEP-0313: Message Archive Management
 * Copyright (C) 2012 Kim Alvefur
 *
 * This file is MIT/X11 licensed. Please see the
 * LICENSE.txt file in the source package for more information.
 *
 * TODO:
 * Get RSM from the reply
 * Clean remove onMessage handler afterwards
 * queryid?
 *
 */

Strophe.addConnectionPlugin('mam', {
  _c: null,
  _p: [ "with", "start", "end" ],
init:
  function(conn) {
    this._c = conn;
    Strophe.addNamespace('MAM', 'urn:xmpp:mam:tmp');
  },
query:
  function(jid, options) {
    var _p = this._p;
    var attr = {type:"get"};
    var mamAttr = {xmlns: Strophe.NS.MAM};
    for (i=0; i < this._p.length; i++) {
      var pn = _p[i];
      var p = options[pn]; delete options[pn];
      if(!!p) {
        attr[pn]=p;
      }
    }
    var onMessage = options["onMessage"]; delete options['onMessage'];
    var onComplete = options["onComplete"]; delete options['onComplete'];
    var iq = $iq(attr).c("query", mamAttr);
    iq.cnode(new Strophe.RSM(options).toXML());
    this._c.addHandler(onMessage, Strophe.NS.MAM, "message", null);
    return this._c.sendIQ(iq, onComplete);
  },
    /* Proposed format for preferences, once implemented:
     *
     * prefs ::= Object
     * prefs.default ::= [ "always" | "never" | "roster" ]
     * prefs.always ::= Array( JID* )
     * prefs.never ::= Array( JID* )
     *
     * Example
     * setPrefs(me, {
     *  default: "roster",
     *  always: [ "alice@wonderland.lit" ],
     *  never: [ "madhatter@wonderland.lit" ]
     * });
     *
getPrefs:
  function(jid) {
  },
setPrefs:
  function(jid, prefs) {
  },
  */
});
<commit_msg>mam: Filter params are child nodes, not attributes<commit_after>/* XEP-0313: Message Archive Management
 * Copyright (C) 2012 Kim Alvefur
 *
 * This file is MIT/X11 licensed. Please see the
 * LICENSE.txt file in the source package for more information.
 *
 * TODO:
 * Get RSM from the reply
 * Clean remove onMessage handler afterwards
 * queryid?
 *
 */

Strophe.addConnectionPlugin('mam', {
  _c: null,
  _p: [ "with", "start", "end" ],
init:
  function(conn) {
    this._c = conn;
    Strophe.addNamespace('MAM', 'urn:xmpp:mam:tmp');
  },
query:
  function(jid, options) {
    var _p = this._p;
    var attr = {type:"get"};
    var mamAttr = {xmlns: Strophe.NS.MAM};
    var iq = $iq(attr).c("query", mamAttr);
    for (i=0; i < this._p.length; i++) {
      var pn = _p[i];
      var p = options[pn]; delete options[pn];
      if(!!p) {
				iq.c(pn).t(p).up();
      }
    }
    var onMessage = options["onMessage"]; delete options['onMessage'];
    var onComplete = options["onComplete"]; delete options['onComplete'];
    iq.cnode(new Strophe.RSM(options).toXML());
    this._c.addHandler(onMessage, Strophe.NS.MAM, "message", null);
    return this._c.sendIQ(iq, onComplete);
  },
    /* Proposed format for preferences, once implemented:
     *
     * prefs ::= Object
     * prefs.default ::= [ "always" | "never" | "roster" ]
     * prefs.always ::= Array( JID* )
     * prefs.never ::= Array( JID* )
     *
     * Example
     * setPrefs(me, {
     *  default: "roster",
     *  always: [ "alice@wonderland.lit" ],
     *  never: [ "madhatter@wonderland.lit" ]
     * });
     *
getPrefs:
  function(jid) {
  },
setPrefs:
  function(jid, prefs) {
  },
  */
});
<|endoftext|>


<commit_before>module.exports = function(res, error) {

  console.log('Error: ', error);
  if (error.stack) {
    console.log(error.stack);
  }

  var err_obj = {
    success: false,
    error: (error.remote ? error.remote.error : null) || error.error || error.message || error.engine_result || error,
    message: (error.remote ? error.remote.error_message : null) || error.error_message || error.message || error.engine_result_message || error
  };

  /* Handle ripple-lib errors */
  if (err_obj.error === 'remoteError') {

    if (err_obj.message === 'Account not found.') {

      err_obj.error = 'Invalid address or secret.';
      err_obj.message = 'Please ensure the address and secret correspond to a valid account that has a positive XRP balance.';

    } else {
      err_obj.error = 'Internal Error';
      err_obj.message = 'ripple-lib reported an error. If the problem persists, please try restarting the server. Error: ' + JSON.stringify(err_obj.message);
    }
  }

  if (err_obj.error === 'Cannot generate keys from invalid seed!') {
    err_obj.error = 'Invalid address or secret.';
    err_obj.message = 'Please ensure the address and secret correspond to a valid account that has a positive XRP balance.';
  }

  /* Handle db errors */
  if (/(relation).*(does not exist)/.test(err_obj.error)){
    var old_error = err_obj.error;
    err_obj.error = 'Database Error';
    err_obj.message = 'This error is likely caused by the setup script failing to execute properly. Please check that PostgreSQL is running on your system and run the setup script again. ' + old_error;
  }

  /* Add info to rippled error messages */

  if (err_obj.error === 'tecPATH_DRY') {
    err_obj.message = err_obj.message + ' Please ensure that the src_address has sufficient funds (in the src_amount currency, if specified) to execute this transaction.';
  }

  if (err_obj.error === 'telINSUF_FEE_P') {
    err_obj.message = err_obj.message + ' Please ensure that the src_address has sufficient XRP to pay the fee. If it does, please report this error, this service should handle setting the proper fee.';
  }

  if (err_obj.error === 'tecPATH_PARTIAL') {
    err_obj.message = err_obj.message + ' Please try getting payment options first to ensure that there is a way to execute this payment. If you submitted a payment from the list of options, the path may have changed already, please try getting payment options again and submitting one of those or setting the "src_slippage" higher.';
  }

  if (err_obj.error === err_obj.message) {
    var err_array = err_obj.error.split('. ');
    err_obj.error = err_array[0];
    err_obj.message = err_array.slice(1).join('. ');
  }

  res.send(err_obj);

};<commit_msg>[CHORE] Added another detailed error message<commit_after>module.exports = function(res, error) {

  console.log('Error: ', error);
  if (error.stack) {
    console.log(error.stack);
  }

  var err_obj = {
    success: false,
    error: (error.remote ? error.remote.error : null) || error.error || error.message || error.engine_result || error,
    message: (error.remote ? error.remote.error_message : null) || error.error_message || error.message || error.engine_result_message || error
  };

  /* Handle ripple-lib errors */
  if (err_obj.error === 'remoteError') {

    if (err_obj.message === 'Account not found.') {

      err_obj.error = 'Invalid address or secret.';
      err_obj.message = 'Please ensure the address and secret correspond to a valid account that has a positive XRP balance.';

    } else {
      err_obj.error = 'Internal Error';
      err_obj.message = 'ripple-lib reported an error. If the problem persists, please try restarting the server. Error: ' + JSON.stringify(err_obj.message);
    }
  }

  if (err_obj.error === 'Cannot generate keys from invalid seed!') {
    err_obj.error = 'Invalid address or secret.';
    err_obj.message = 'Please ensure the address and secret correspond to a valid account that has a positive XRP balance.';
  }

  if (err_obj.error === 'tooBusy') {
    err_obj.error = 'Rippled Busy';
    err_obj.message = 'The server is experiencing heavy load and is unable to process the request right now. Please try again.';
  }

  /* Handle db errors */
  if (/(relation).*(does not exist)/.test(err_obj.error)){
    var old_error = err_obj.error;
    err_obj.error = 'Database Error';
    err_obj.message = 'This error is likely caused by the setup script failing to execute properly. Please check that PostgreSQL is running on your system and run the setup script again. ' + old_error;
  }

  /* Add info to rippled error messages */

  if (err_obj.error === 'tecPATH_DRY') {
    err_obj.message = err_obj.message + ' Please ensure that the src_address has sufficient funds (in the src_amount currency, if specified) to execute this transaction.';
  }

  if (err_obj.error === 'telINSUF_FEE_P') {
    err_obj.message = err_obj.message + ' Please ensure that the src_address has sufficient XRP to pay the fee. If it does, please report this error, this service should handle setting the proper fee.';
  }

  if (err_obj.error === 'tecPATH_PARTIAL') {
    err_obj.message = err_obj.message + ' Please try getting payment options first to ensure that there is a way to execute this payment. If you submitted a payment from the list of options, the path may have changed already, please try getting payment options again and submitting one of those or setting the "src_slippage" higher.';
  }

  if (err_obj.error === err_obj.message) {
    var err_array = err_obj.error.split('. ');
    err_obj.error = err_array[0];
    err_obj.message = err_array.slice(1).join('. ');
  }

  res.send(err_obj);

};<|endoftext|>


<commit_before>goog.provide('ngeo.mapDirective');

goog.require('goog.asserts');
goog.require('ngeo');
goog.require('ngeo.SyncDataSourcesMap');
goog.require('ol.Map');

/**
 * Provides a directive used to insert a user-defined OpenLayers
 * map in the DOM. The directive does not create an isolate scope.
 *
 * Examples:
 *
 *   Simple:
 *
 *

 *
 *   Manage window resizing:
 *
 *

 *

 *
 * See our live examples:
 * [../examples/permalink.html](../examples/permalink.html)
 * [../examples/simple.html](../examples/simple.html)
 *
 * @htmlAttribute {ol.Map} ngeo-map The map.
 * @param {ngeo.SyncDataSourcesMap} ngeoSyncDataSourcesMap Ngeo sync
 *     data sources map service.
 * @return {angular.Directive} Directive Definition Object.
 * @ngInject
 * @ngdoc directive
 * @ngname ngeoMap
 */
ngeo.mapDirective = function(ngeoSyncDataSourcesMap) {
  return {
    restrict: 'A',
    /**
     * @param {angular.Scope} scope Scope.
     * @param {angular.JQLite} element Element.
     * @param {angular.Attributes} attrs Atttributes.
     */
    link(scope, element, attrs) {
      // Get the 'ol.Map' object from attributes and manage it accordingly
      const attr = 'ngeoMap';
      const prop = attrs[attr];

      const map = scope.$eval(prop);
      goog.asserts.assertInstanceof(map, ol.Map);

      map.setTarget(element[0]);

      ngeoSyncDataSourcesMap.map = map;

      // Get the 'window resize' attributes, which are optionnal. If defined,
      // the browser window 'resize' event is listened to update the size of
      // the map when fired. A transition option is also available to let any
      // animation that may occur on the div of the map to smootly resize the
      // map while in progress.
      const manageResizeAttr = 'ngeoMapManageResize';
      const manageResizeProp = attrs[manageResizeAttr];
      const manageResize = scope.$eval(manageResizeProp);

      if (manageResize) {
        const resizeTransitionAttr = 'ngeoMapResizeTransition';
        const resizeTransitionProp = attrs[resizeTransitionAttr];
        const resizeTransition = scope.$eval(resizeTransitionProp);

        ol.events.listen(
          window,
          'resize',
          () => {
            if (resizeTransition && Number.isInteger(resizeTransition)) {
              // Resize with transition
              const start = Date.now();
              let loop = true;
              const adjustSize = function() {
                map.updateSize();
                map.renderSync();
                if (loop) {
                  window.requestAnimationFrame(adjustSize);
                }
                if (Date.now() - start > resizeTransition) {
                  loop = false;
                }
              };
              adjustSize();
            } else {
              // A single plain resize
              map.updateSize();
            }
          },
          this
        );
      }
    }
  };
};

ngeo.module.directive('ngeoMap', ngeo.mapDirective);
<commit_msg>Apply reviewer's comments<commit_after>goog.provide('ngeo.mapDirective');

goog.require('goog.asserts');
goog.require('ngeo');
goog.require('ngeo.SyncDataSourcesMap');
goog.require('ol.Map');

/**
 * Provides a directive used to insert a user-defined OpenLayers
 * map in the DOM. The directive does not create an isolate scope.
 *
 * Examples:
 *
 *   Simple:
 *
 *

 *
 *   Manage window resizing:
 *
 *

 *

 *
 * See our live examples:
 * [../examples/permalink.html](../examples/permalink.html)
 * [../examples/simple.html](../examples/simple.html)
 *
 * @htmlAttribute {ol.Map} ngeo-map The map.
 * @param {angular.$window} $window The Angular $window service.
 * @param {ngeo.SyncDataSourcesMap} ngeoSyncDataSourcesMap Ngeo sync
 *     data sources map service.
 * @return {angular.Directive} Directive Definition Object.
 * @ngInject
 * @ngdoc directive
 * @ngname ngeoMap
 */
ngeo.mapDirective = function($window, ngeoSyncDataSourcesMap) {
  return {
    restrict: 'A',
    /**
     * @param {angular.Scope} scope Scope.
     * @param {angular.JQLite} element Element.
     * @param {angular.Attributes} attrs Atttributes.
     */
    link(scope, element, attrs) {
      // Get the 'ol.Map' object from attributes and manage it accordingly
      const attr = 'ngeoMap';
      const prop = attrs[attr];

      const map = scope.$eval(prop);
      goog.asserts.assertInstanceof(map, ol.Map);

      map.setTarget(element[0]);

      ngeoSyncDataSourcesMap.map = map;

      // Get the 'window resize' attributes, which are optionnal. If defined,
      // the browser window 'resize' event is listened to update the size of
      // the map when fired. A transition option is also available to let any
      // animation that may occur on the div of the map to smootly resize the
      // map while in progress.
      const manageResizeAttr = 'ngeoMapManageResize';
      const manageResizeProp = attrs[manageResizeAttr];
      const manageResize = scope.$eval(manageResizeProp);

      if (manageResize) {
        const resizeTransitionAttr = 'ngeoMapResizeTransition';
        const resizeTransitionProp = attrs[resizeTransitionAttr];
        /** @type {number|undefined} */
        const resizeTransition = scope.$eval(resizeTransitionProp);

        ol.events.listen(
          $window,
          'resize',
          () => {
            if (resizeTransition) {
              // Resize with transition
              const start = Date.now();
              let loop = true;
              const adjustSize = function() {
                map.updateSize();
                map.renderSync();
                if (loop) {
                  $window.requestAnimationFrame(adjustSize);
                }
                if (Date.now() - start > resizeTransition) {
                  loop = false;
                }
              };
              adjustSize();
            } else {
              // A single plain resize
              map.updateSize();
            }
          }
        );
      }
    }
  };
};

ngeo.module.directive('ngeoMap', ngeo.mapDirective);
<|endoftext|>


<commit_before>var User = require('../models/User');
var {downloadGoogleSpreadsheet} = require('../libs/downloadingFile');

/**
 * POST /notification
 * receive a notification that one of the files has been changed.
 */
exports.postNotification = function(req, res, next) {
  console.log('req:', req);

  var uidArr = req.headers['x-goog-channel-id'].split('__user:');
  var userId = uidArr[1];
  var fileId = uidArr[0].replace(/^file:/, '');

  var user = User.findById(userId, function(err, user) {
    if (err) {
      console.log(err);
    }
  });
  var token = _.find(user.tokens, { kind: 'google' });
  var file = req.user.googleFiles.find(f => f.id === fileId);

  downloadGoogleSpreadsheet(token, file, () => {
    genSchema();
    console.log('done')
  });

  user.apiFiles = user.apiFiles.map(f => f.id === fileId ? file : f);

  res.status(200).send('OK');

}
<commit_msg>requiring lodash<commit_after>var User = require('../models/User');
var {downloadGoogleSpreadsheet} = require('../libs/downloadingFile');
var _ = require('lodash');

/**
 * POST /notification
 * receive a notification that one of the files has been changed.
 */
exports.postNotification = function(req, res, next) {
  console.log('req:', req);

  var uidArr = req.headers['x-goog-channel-id'].split('__user:');
  var userId = uidArr[1];
  var fileId = uidArr[0].replace(/^file:/, '');

  var user = User.findById(userId, function(err, user) {
    if (err) {
      console.log(err);
    }
  });
  var token = _.find(user.tokens, { kind: 'google' });
  var file = req.user.googleFiles.find(f => f.id === fileId);

  downloadGoogleSpreadsheet(token, file, () => {
    genSchema();
    console.log('done')
  });

  user.apiFiles = user.apiFiles.map(f => f.id === fileId ? file : f);

  res.status(200).send('OK');

}
<|endoftext|>


<commit_before>/*
 * Copyright 2010 Research In Motion Limited.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @toc {BBM} BBM Platform
 * @featureID blackberry.bbm.platform
 * @permission bbm_connect BBM APIs require this permission to be set
 * @namespace
 * The BBM Social Platform (BBMSP) provides APIs that allow you to leverage the social features and functionality of BlackBerry Messenger from within your app.
 * @notice {Required BBM Version} BBM Social Platform APIs come with BBM 6.1.0 and later. BBM 6.1.0 is supported on BlackBerry OS 5, 6, and 7.
 * @notice {Authorization}
 * Applications must first obtain access to the platform by calling
 * {@link blackberry.bbm.platform.register}.
 *

 *
Accessing other namespaces under {@link blackberry.bbm.platform} may throw exceptions
 * if not authorized.

 *
Authorization may be revoked by the user or server at any time.

 *

 * @BB50+
 * @learns {Download BBM SDK Resources} http://us.blackberry.com/developers/blackberrymessenger/ Download the resources required to use the BBM SDK for WebWorks [BlackBerry].
 * @learns {Getting Started Guide} https://bdsc.webapps.blackberry.com/html5/documentation/ww_services/bbm_sdk_for_ww_1878476_11.html Setup the BBM SDK for BlackBerry WebWorks [BlackBerry Developer Resource Center].
 * @learns {Sample Application Guide} http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Getting-Started-BlackBerry-WebWorks-Development-for-Smartphones/ta-p/1185353 Get started with the sample application included with the BBM SDK for BlackBerry WebWorks [BlackBerry Developer Resource Center].
 */
blackberry.bbm.platform = {

    /**
     * @name blackberry.bbm.platform.register^2
     * @function
     * @description Registers your app to allow it to access the BBM Social Platform.
     *
The application must assign a callback to {@link blackberry.bbm.platform.event:onaccesschanged}
     * before registering. During registration, a dialog opens and guides the user through the registration process.
     * The application should wait until {@link blackberry.bbm.platform.event:onaccesschanged} is invoked before continuing.

     *
Application in Test Environment

     * Applications must provide a UUID used to identify the application in the test
     * environment. If the application is in App World, the UUID will not be used. The same
     * UUID should be used for future releases of the same application; otherwise communication
     * between them will not be possible. The UUID must be a randomly generated 36-character UUID.
     * Any UUID generator can be used.
     * @param {Object} options Options.
     * @param {String} options.uuid ID used to identify the application in the test environment.
     * @example
     * <script type="text/javascript">
     *
     * // Create callback invoked when access changes
     * blackberry.event.addEventListner("onaccesschanged", accessChangedCallback);
     *
     * function accessChangedCallback(accessible, status) {
     *     if (status == "unregistered") {
     *         // App is unregistered, proceed to register
     *         registerApp();
     *     } else if (status == "allowed") {
     *         // Access allowed
     *     }
     *     // Listen for other status...
     * };
     *
     * function registerApp() {
     * // Register with the platform
     *      blackberry.bbm.platform.register({
     *          uuid: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" // Randomly generated UUID
     *      });
     * }
     *
     * </script>
     * @BB10X
     */

     /**
     * @description Registers your app to allow it to access the BBM Social Platform.
     *
The application must assign a callback to {@link blackberry.bbm.platform.event:onaccesschanged}
     * before registering. During registration, a dialog opens and guides the user through the registration process.
     * The application should wait until {@link blackberry.bbm.platform.event:onaccesschanged} is invoked before continuing.

     *
Application in Test Environment

     * Applications must provide a UUID that will be used to identify the application in the test
     * environment. If the application is in App World, the UUID will not be used. The same
     * UUID should be used for future releases of the same application; otherwise communication
     * between them will not be possible. The UUID must be a randomly generated 36-character UUID.
     * Any UUID generator can be used.
     * @param {Object} options Options.
     * @param {String} options.uuid ID used to identify the application in the test environment.
     * @throws {IllegalStateException} If blackberry.bbm.platform.onaccesschanged is not assigned.
     * @throws {IllegalArgumentException} If UUID is not a valid 36-character UUID.
     * @example
     * <script type="text/javascript">
     *
     * // Create callback invoked when access changes
     * blackberry.event.addEventListner("onaccesschanged", accessChangedCallback);
     *
     * function accessChangedCallback(accessible, status) {
     *     if  (status == "allowed") {
     *         // Access allowed
     *     } else if (status == "user") {
     *         // Access blocked by user
     *     } else if (status == "rim") {
     *         // Access blocked by RIM
     *     }
     *     // Listen for other status...
     * };
     *
     * // Register with the platform
     * blackberry.bbm.platform.register({
     *     uuid: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" // Randomly generated UUID
     * });
     *
     * </script>
     * @BB50+
     */
    register : function(options) {
    },

    /**
     * @description Shows a dialog prompting the user to connect the application to BBM. This will
     * only work if the application is blocked by the user (i.e. access status is "user").
     *
If the user decides to connect, the application should call {@link blackberry.bbm.platform.register}
     * to complete connecting the application to BBM.
     * @param {Function} onComplete Called when the user has finished connecting the application to BBM.
     * @param {Boolean} connected true if the user connected the application to BBM;
     * false otherwise.
     * @example
     * <script type="text/javascript">
     *
     * // Prompt the user to connect to BBM, and if the user connects, call register()
     * blackberry.bbm.platform.requestUserPermission(function(allowed) {
     *     if(allowed) {
     *         // Register with the platform
     *         blackberry.bbm.platform.register({
     *             uuid: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" // Randomly generated UUID
     *         });
     *     }
     * });
     *
     * </script>
     * @deprecated Use {@link blackberry.bbm.platform.showBBMAppOptions}
     * @BB50+
     */
    requestUserPermission : function(onComplete) {
    },

    /**
     * @description Brings the BBM options screen for the application to the foreground. This
     * method can only be called if the access status is "allowed" or blocked by
     * "user". Otherwise this method does nothing.
     * @param {Function} onComplete Called when the user exits the BBM options screen.
     * @example
     * <script type="text/javascript">
     *
     * blackberry.bbm.platform.showBBMAppOptions(function() {
     *     // User exited the BBM options screen
     * });
     *
     * </script>
     *
     * @BB50+
     */
    showBBMAppOptions: function(onComplete) {
    },

    /**
     * @name blackberry.bbm.platform.onaccesschanged^2
     * @description This event is fired by the system. If you want to listen to the event, you can use the {@link blackberry.event.addEventListener} function and remove the listener using the {@link blackberry.event.removeEventListener} function.

     * @description Registers for access to the BBM Social Platform.
     *
The application must assign a callback by adding an event listener {@link blackberry.bbm.platform.event:onaccesschanged} before registering or attemping to use any BBM related functions.
     * @param {Boolean} accessible Flag if the BBM Social Platform access is allowed.
     * @param {String} status Status message of current BBMSP access.
     *

     *
"allowed": Access is allowed.
     *
"unregistered": Access is blocked because the application is currently not registered.
     *
"pending": Access is pending and being processed.
     *
"user": Access is blocked by the user.
     *
"rim": Access is blocked by RIM (the application has most likely violated the terms of use).
     *
"nodata": Access is blocked because the device is out of data coverage. A data connection is required to register the application.
     *
"unexpectederror": Access is blocked because an unexpected error has occured.
     *
"invaliduuid": Access is blocked because an invalid UUID was provided when registering.
     *
"temperror": Access is blocked because of a temporary error. The application should try to call
     * {@link blackberry.bbm.platform.register} in 30 minutes, or the next time the application starts.
     * @example
     * <script type="text/javascript">
     *
     * // Create callback invoked when access changes
     * blackberry.event.addEventListner("onaccesschanged", accessChangedCallback);
     *
     * function accessChangedCallback(accessible, status) {
     *     if  (status == "allowed") {
     *         // Access allowed
     *     } else if (status == "user") {
     *         // Access blocked by user
     *     } else if (status == "rim") {
     *         // Access blocked by RIM
     *     }
     *     // Listen for other status...
     *     };
     *
     * </script>
     * @event
     * @BB10X
     */

    /**
     * Called when the access status changes.
     *
This callback is mandatory and must be assigned before the call to {@link blackberry.bbm.platform.register}.
     * @param {Boolean} accessible true if access is allowed;
     * false otherwise.
     * @param {String} status The access status.
     *

     *
"allowed": Access is allowed.
     *
"user": Access is blocked by the user.
     *
"rim": Access is blocked by RIM (the application has most likely violated the terms of use).
     *
"itpolicy": Access is blocked by IT Policy.
     *
"resetrequired": Access is blocked because a device reset is required to use the BBM Social Platform.
     *
"nodata": Access is blocked because the device is out of data coverage. A data connection is required to register the application.
     *
"temperror": Access is blocked because of a temporary error. The application should try to call
     * {@link blackberry.bbm.platform.register} in 30 minutes, or the next time the application starts.
     *
"nonuiapp": Access is blocked because {@link blackberry.bbm.platform.register} was called from a non-UI application.
     *
The application must initially register from a UI application because user interaction is required. The application may register from a background application only after the application has been connected in a UI application at least once.

     *

     * @event
     * @BB50+
     */
    onaccesschanged : function(accessible, status) {
    },

    /**
     * Called in certain cases when the application is invoked from within BBM.
     *
The param and user parameters are dictated by the invocation reason.
     *
     *
This callback should be assigned before the call to {@link blackberry.bbm.platform.register}. If the application is not running, it will be launched. This callback will only be invoked after access to the BBM Social Platform is allowed.
     *
This callback is optional. Applications are not required to handle this type of event.
     *
     * @param {String} reason The reason that the application was invoked.
     *

     *
"profilebox": A user's profile box item was clicked.
     *
param is the {@link blackberry.bbm.platform.self.profilebox.ProfileBoxItem} that was clicked.
     *
See {@link blackberry.bbm.platform.self.profilebox}.

     *
"profileboxtitle": A user's profile box title was clicked.
     *
param is undefined.
     *
See {@link blackberry.bbm.platform.self.profilebox}.

     *
"personalmessage": A user's personal message app link was clicked.
     *
param is the personal message, excluding the app link.
     *
See {@link blackberry.bbm.platform.self.setPersonalMessage}.

     *
"chatmessage": A user's chat message app link was clicked.
     *
param is undefined.
     *
See {@link blackberry.bbm.platform.users.startBBMChat}.

     *

     * @param {void} param The parameter associated with reason. May be undefined.
     * @param {blackberry.bbm.platform.users.BBMPlatformUser | blackberry.bbm.platform.self} user The
     * user whose personal message/profile box/etc. was clicked. May be undefined.
     * @example
     * <script type="text/javascript">
     *
     * blackberry.bbm.platform.onappinvoked = function(reason, param, user) {
     *     // User clicked a user's profile box
     *     if(reason == "profileboxtitle") {
     *         // e.g. Show detail for user's whole TPA profile box
     *
     *     // User clicked a user's profile box item
     *     } else if(reason == "profilebox") {
     *         // e.g. Show the score and trophy represented by a profile box item
     *         var item = param;
     *         var score = item.cookie;
     *
     *     // User clicked a user's personal message TPA link
     *     } else if(reason == "personalmessage") {
     *         // e.g. Allow the user to comment on the user's personal message in the user's TPA profile
     *         var personalMessage = param;
     *
     *     // User clicked a contact's chat message TPA link
     *     } else if(reason == "chatmessage") {
     *         // e.g. Start an activity with the contact
     *
     *     }
     * }
     *
     * </script>
     * @event
     * @BB50+
     */
    onappinvoked : function(reason, param, user) {
    },

    /**
     * The application environment.
     *

     *
"appworld": The application exists in App World.
     *
"test": The application does not exist in App World.
     *

     * @type String
     * @readOnly
     * @BB50+
     */
    environment : ""
};
<commit_msg>Fixes a type in the bbm docs.<commit_after>/*
 * Copyright 2010 Research In Motion Limited.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @toc {BBM} BBM Platform
 * @featureID blackberry.bbm.platform
 * @permission bbm_connect BBM APIs require this permission to be set
 * @namespace
 * The BBM Social Platform (BBMSP) provides APIs that allow you to leverage the social features and functionality of BlackBerry Messenger from within your app.
 * @notice {Required BBM Version} BBM Social Platform APIs come with BBM 6.1.0 and later. BBM 6.1.0 is supported on BlackBerry OS 5, 6, and 7.
 * @notice {Authorization}
 * Applications must first obtain access to the platform by calling
 * {@link blackberry.bbm.platform.register}.
 *

 *
Accessing other namespaces under {@link blackberry.bbm.platform} may throw exceptions
 * if not authorized.

 *
Authorization may be revoked by the user or server at any time.

 *

 * @BB50+
 * @learns {Download BBM SDK Resources} http://us.blackberry.com/developers/blackberrymessenger/ Download the resources required to use the BBM SDK for WebWorks [BlackBerry].
 * @learns {Getting Started Guide} https://bdsc.webapps.blackberry.com/html5/documentation/ww_services/bbm_sdk_for_ww_1878476_11.html Setup the BBM SDK for BlackBerry WebWorks [BlackBerry Developer Resource Center].
 * @learns {Sample Application Guide} http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Getting-Started-BlackBerry-WebWorks-Development-for-Smartphones/ta-p/1185353 Get started with the sample application included with the BBM SDK for BlackBerry WebWorks [BlackBerry Developer Resource Center].
 */
blackberry.bbm.platform = {

    /**
     * @name blackberry.bbm.platform.register^2
     * @function
     * @description Registers your app to allow it to access the BBM Social Platform.
     *
The application must assign a callback to {@link blackberry.bbm.platform.event:onaccesschanged}
     * before registering. During registration, a dialog opens and guides the user through the registration process.
     * The application should wait until {@link blackberry.bbm.platform.event:onaccesschanged} is invoked before continuing.

     *
Application in Test Environment

     * Applications must provide a UUID used to identify the application in the test
     * environment. If the application is in App World, the UUID will not be used. The same
     * UUID should be used for future releases of the same application; otherwise communication
     * between them will not be possible. The UUID must be a randomly generated 36-character UUID.
     * Any UUID generator can be used.
     * @param {Object} options Options.
     * @param {String} options.uuid ID used to identify the application in the test environment.
     * @example
     * <script type="text/javascript">
     *
     * // Create callback invoked when access changes
     * blackberry.event.addEventListener("onaccesschanged", accessChangedCallback);
     *
     * function accessChangedCallback(accessible, status) {
     *     if (status == "unregistered") {
     *         // App is unregistered, proceed to register
     *         registerApp();
     *     } else if (status == "allowed") {
     *         // Access allowed
     *     }
     *     // Listen for other status...
     * };
     *
     * function registerApp() {
     * // Register with the platform
     *      blackberry.bbm.platform.register({
     *          uuid: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" // Randomly generated UUID
     *      });
     * }
     *
     * </script>
     * @BB10X
     */

     /**
     * @description Registers your app to allow it to access the BBM Social Platform.
     *
The application must assign a callback to {@link blackberry.bbm.platform.event:onaccesschanged}
     * before registering. During registration, a dialog opens and guides the user through the registration process.
     * The application should wait until {@link blackberry.bbm.platform.event:onaccesschanged} is invoked before continuing.

     *
Application in Test Environment

     * Applications must provide a UUID that will be used to identify the application in the test
     * environment. If the application is in App World, the UUID will not be used. The same
     * UUID should be used for future releases of the same application; otherwise communication
     * between them will not be possible. The UUID must be a randomly generated 36-character UUID.
     * Any UUID generator can be used.
     * @param {Object} options Options.
     * @param {String} options.uuid ID used to identify the application in the test environment.
     * @throws {IllegalStateException} If blackberry.bbm.platform.onaccesschanged is not assigned.
     * @throws {IllegalArgumentException} If UUID is not a valid 36-character UUID.
     * @example
     * <script type="text/javascript">
     *
     * // Create callback invoked when access changes
     * blackberry.event.addEventListener("onaccesschanged", accessChangedCallback);
     *
     * function accessChangedCallback(accessible, status) {
     *     if  (status == "allowed") {
     *         // Access allowed
     *     } else if (status == "user") {
     *         // Access blocked by user
     *     } else if (status == "rim") {
     *         // Access blocked by RIM
     *     }
     *     // Listen for other status...
     * };
     *
     * // Register with the platform
     * blackberry.bbm.platform.register({
     *     uuid: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" // Randomly generated UUID
     * });
     *
     * </script>
     * @BB50+
     */
    register : function(options) {
    },

    /**
     * @description Shows a dialog prompting the user to connect the application to BBM. This will
     * only work if the application is blocked by the user (i.e. access status is "user").
     *
If the user decides to connect, the application should call {@link blackberry.bbm.platform.register}
     * to complete connecting the application to BBM.
     * @param {Function} onComplete Called when the user has finished connecting the application to BBM.
     * @param {Boolean} connected true if the user connected the application to BBM;
     * false otherwise.
     * @example
     * <script type="text/javascript">
     *
     * // Prompt the user to connect to BBM, and if the user connects, call register()
     * blackberry.bbm.platform.requestUserPermission(function(allowed) {
     *     if(allowed) {
     *         // Register with the platform
     *         blackberry.bbm.platform.register({
     *             uuid: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" // Randomly generated UUID
     *         });
     *     }
     * });
     *
     * </script>
     * @deprecated Use {@link blackberry.bbm.platform.showBBMAppOptions}
     * @BB50+
     */
    requestUserPermission : function(onComplete) {
    },

    /**
     * @description Brings the BBM options screen for the application to the foreground. This
     * method can only be called if the access status is "allowed" or blocked by
     * "user". Otherwise this method does nothing.
     * @param {Function} onComplete Called when the user exits the BBM options screen.
     * @example
     * <script type="text/javascript">
     *
     * blackberry.bbm.platform.showBBMAppOptions(function() {
     *     // User exited the BBM options screen
     * });
     *
     * </script>
     *
     * @BB50+
     */
    showBBMAppOptions: function(onComplete) {
    },

    /**
     * @name blackberry.bbm.platform.onaccesschanged^2
     * @description This event is fired by the system. If you want to listen to the event, you can use the {@link blackberry.event.addEventListener} function and remove the listener using the {@link blackberry.event.removeEventListener} function.

     * @description Registers for access to the BBM Social Platform.
     *
The application must assign a callback by adding an event listener {@link blackberry.bbm.platform.event:onaccesschanged} before registering or attemping to use any BBM related functions.
     * @param {Boolean} accessible Flag if the BBM Social Platform access is allowed.
     * @param {String} status Status message of current BBMSP access.
     *

     *
"allowed": Access is allowed.
     *
"unregistered": Access is blocked because the application is currently not registered.
     *
"pending": Access is pending and being processed.
     *
"user": Access is blocked by the user.
     *
"rim": Access is blocked by RIM (the application has most likely violated the terms of use).
     *
"nodata": Access is blocked because the device is out of data coverage. A data connection is required to register the application.
     *
"unexpectederror": Access is blocked because an unexpected error has occured.
     *
"invaliduuid": Access is blocked because an invalid UUID was provided when registering.
     *
"temperror": Access is blocked because of a temporary error. The application should try to call
     * {@link blackberry.bbm.platform.register} in 30 minutes, or the next time the application starts.
     * @example
     * <script type="text/javascript">
     *
     * // Create callback invoked when access changes
     * blackberry.event.addEventListner("onaccesschanged", accessChangedCallback);
     *
     * function accessChangedCallback(accessible, status) {
     *     if  (status == "allowed") {
     *         // Access allowed
     *     } else if (status == "user") {
     *         // Access blocked by user
     *     } else if (status == "rim") {
     *         // Access blocked by RIM
     *     }
     *     // Listen for other status...
     *     };
     *
     * </script>
     * @event
     * @BB10X
     */

    /**
     * Called when the access status changes.
     *
This callback is mandatory and must be assigned before the call to {@link blackberry.bbm.platform.register}.
     * @param {Boolean} accessible true if access is allowed;
     * false otherwise.
     * @param {String} status The access status.
     *

     *
"allowed": Access is allowed.
     *
"user": Access is blocked by the user.
     *
"rim": Access is blocked by RIM (the application has most likely violated the terms of use).
     *
"itpolicy": Access is blocked by IT Policy.
     *
"resetrequired": Access is blocked because a device reset is required to use the BBM Social Platform.
     *
"nodata": Access is blocked because the device is out of data coverage. A data connection is required to register the application.
     *
"temperror": Access is blocked because of a temporary error. The application should try to call
     * {@link blackberry.bbm.platform.register} in 30 minutes, or the next time the application starts.
     *
"nonuiapp": Access is blocked because {@link blackberry.bbm.platform.register} was called from a non-UI application.
     *
The application must initially register from a UI application because user interaction is required. The application may register from a background application only after the application has been connected in a UI application at least once.

     *

     * @event
     * @BB50+
     */
    onaccesschanged : function(accessible, status) {
    },

    /**
     * Called in certain cases when the application is invoked from within BBM.
     *
The param and user parameters are dictated by the invocation reason.
     *
     *
This callback should be assigned before the call to {@link blackberry.bbm.platform.register}. If the application is not running, it will be launched. This callback will only be invoked after access to the BBM Social Platform is allowed.
     *
This callback is optional. Applications are not required to handle this type of event.
     *
     * @param {String} reason The reason that the application was invoked.
     *

     *
"profilebox": A user's profile box item was clicked.
     *
param is the {@link blackberry.bbm.platform.self.profilebox.ProfileBoxItem} that was clicked.
     *
See {@link blackberry.bbm.platform.self.profilebox}.

     *
"profileboxtitle": A user's profile box title was clicked.
     *
param is undefined.
     *
See {@link blackberry.bbm.platform.self.profilebox}.

     *
"personalmessage": A user's personal message app link was clicked.
     *
param is the personal message, excluding the app link.
     *
See {@link blackberry.bbm.platform.self.setPersonalMessage}.

     *
"chatmessage": A user's chat message app link was clicked.
     *
param is undefined.
     *
See {@link blackberry.bbm.platform.users.startBBMChat}.

     *

     * @param {void} param The parameter associated with reason. May be undefined.
     * @param {blackberry.bbm.platform.users.BBMPlatformUser | blackberry.bbm.platform.self} user The
     * user whose personal message/profile box/etc. was clicked. May be undefined.
     * @example
     * <script type="text/javascript">
     *
     * blackberry.bbm.platform.onappinvoked = function(reason, param, user) {
     *     // User clicked a user's profile box
     *     if(reason == "profileboxtitle") {
     *         // e.g. Show detail for user's whole TPA profile box
     *
     *     // User clicked a user's profile box item
     *     } else if(reason == "profilebox") {
     *         // e.g. Show the score and trophy represented by a profile box item
     *         var item = param;
     *         var score = item.cookie;
     *
     *     // User clicked a user's personal message TPA link
     *     } else if(reason == "personalmessage") {
     *         // e.g. Allow the user to comment on the user's personal message in the user's TPA profile
     *         var personalMessage = param;
     *
     *     // User clicked a contact's chat message TPA link
     *     } else if(reason == "chatmessage") {
     *         // e.g. Start an activity with the contact
     *
     *     }
     * }
     *
     * </script>
     * @event
     * @BB50+
     */
    onappinvoked : function(reason, param, user) {
    },

    /**
     * The application environment.
     *

     *
"appworld": The application exists in App World.
     *
"test": The application does not exist in App World.
     *

     * @type String
     * @readOnly
     * @BB50+
     */
    environment : ""
};
<|endoftext|>


<commit_before>(function() {
  ko.bindingHandlers.contextMenu = {
    init: function (element, valueAccessor) {
      var value = valueAccessor();
      var clickEvent;
      $(element).contextmenu({
        target: value.target,
        before: function (e, context) {
          clickEvent = e;
          return value.before ? value.before(e, context) : true;
        },
        scopes: value.scopes || null,
        onItem: function (context, e) {
          var data = ko.dataFor(context.first().get()[0]);
          var action = $(e.target).text();
          value.onItem(action, data || context, clickEvent);
        }
      });
    }
  };

  ko.bindingHandlers.beforeUnloadText = {
    init: function (element, valueAccessor) {
      $(window).on('beforeunload', function() {
        var value = ko.unwrap(valueAccessor());
        if (value && value !== null) {
          return value;
        }
      });
    }
  };

  ko.bindingHandlers.terminal = {
    init: function (element, valueAccessor) {
      var options = valueAccessor();
      var terminal = $(element).terminal(options.onCommand, {
        greetings: '',
        prompt: '>> ',
        clear: false,
        exit: false,
        login: false,
      });
      if (!ko.unwrap(options.enabled)) {
        terminal.pause();
        terminal.echo('Preparing interpreter...');
      }
      $(element).data('terminal', terminal);
    },

    update: function (element, valueAccessor) {
      var terminal = $(element).data('terminal');
      var options = valueAccessor();
      if (ko.unwrap(options.enabled) && terminal.paused()) {
        terminal.clear();
        terminal.resume();
      }
    },
  }
})();
<commit_msg>Fix for shell keeping focus when modal appears.<commit_after>(function() {
  ko.bindingHandlers.contextMenu = {
    init: function (element, valueAccessor) {
      var value = valueAccessor();
      var clickEvent;
      $(element).contextmenu({
        target: value.target,
        before: function (e, context) {
          clickEvent = e;
          return value.before ? value.before(e, context) : true;
        },
        scopes: value.scopes || null,
        onItem: function (context, e) {
          var data = ko.dataFor(context.first().get()[0]);
          var action = $(e.target).text();
          value.onItem(action, data || context, clickEvent);
        }
      });
    }
  };

  ko.bindingHandlers.beforeUnloadText = {
    init: function (element, valueAccessor) {
      $(window).on('beforeunload', function() {
        var value = ko.unwrap(valueAccessor());
        if (value && value !== null) {
          return value;
        }
      });
    }
  };

  ko.bindingHandlers.terminal = {
    init: function (element, valueAccessor) {
      var options = valueAccessor();
      var terminal = $(element).terminal(options.onCommand, {
        greetings: '',
        prompt: '>> ',
        clear: false,
        exit: false,
        login: false,
      });
      if (!ko.unwrap(options.enabled)) {
        terminal.pause();
        terminal.echo('Preparing interpreter...');
      }
      $(element).data('terminal', terminal);

      // This fixes a problem where the terminal keeps stealing keystrokes when
      // a context menu spawns a modal, even though it doesn't have focus
      // anymore. See https://github.com/jcubic/jquery.terminal/issues/169.
      $(document).on('show.bs.context', function () {
        if (terminal.enabled()) {
          terminal.disable();
        }
      });
    },

    update: function (element, valueAccessor) {
      var terminal = $(element).data('terminal');
      var options = valueAccessor();
      if (ko.unwrap(options.enabled) && terminal.paused()) {
        terminal.clear();
        terminal.resume();
      }
    },
  }
})();
<|endoftext|>